# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=pydocstyle
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=6.3.0
pkgrel=3
pkgdesc='Python docstring style checker (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
license=('MIT')
url='https://github.com/PyCQA/pydocstyle'
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-snowballstemmer)
makedepends=(${MINGW_PACKAGE_PREFIX}-python-build
             ${MINGW_PACKAGE_PREFIX}-python-installer
             ${MINGW_PACKAGE_PREFIX}-python-poetry-core)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r ${_realname}-${pkgver} python-build-${MSYSTEM}
}

build() {
  cd ${srcdir}/python-build-${MSYSTEM}
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd ${srcdir}/python-build-${MSYSTEM}
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE-MIT "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
